package com.xxx.lease.common.exception;

import com.xxx.lease.common.result.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/*
*   全局异常处理器
* */

@ControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result exception1(Exception e) {
        e.printStackTrace();
        return Result.fail(500, e.getMessage());
    }

    @ExceptionHandler(LeaseException.class)
    @ResponseBody
    public Result exception1(LeaseException e) {
        e.printStackTrace();
        return Result.fail(500, e.getMessage());
    }
}
